using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using DTO;

using System.Data;

namespace Business
{
    public class ChiTietPhieuThueService
    {




		//////////////////////////////////////////////////////////

 		                                                         

		//            Enter code your here                      //

		                                                         

		//////////////////////////////////////////////////////////

       static public DataTable ConvertListChiTietPhieuThueDTOToDataTable( List<ChiTietPhieuThueDTO> lst)
       {
               DataTable dt = new DataTable();
           dt.Columns.Add( "MaChiTietPhieuThue");
           dt.Columns.Add( "MaKhachHang");
           dt.Columns.Add( "MaPhieuThue");
           for( int i = 0; i < lst.Count; i ++)
           {
               dt.Rows.Add(
                       lst[i].MaChiTietPhieuThue,      
                       lst[i].MaKhachHang,      
                       lst[i].MaPhieuThue      
                   );
           }
               return dt;
       }
        static public int GetIdentity()
        {
            Data.ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
            return repo.GetIdentity();
        }

        static public int Count()
        {
            return ChiTietPhieuThueRepository.Count();
        }
        public static bool Them(ChiTietPhieuThueDTO objDTO)
        {
                ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
                return repo.Them(objDTO);
        }

        public static bool Xoa(int MaChiTietPhieuThue, bool XoaKhoaNgoai=false)
        {
              ChiTietPhieuThueRepository Repo = new ChiTietPhieuThueRepository();
              return Repo.Xoa(MaChiTietPhieuThue,XoaKhoaNgoai);
        }

        public static void CapNhat(ChiTietPhieuThueDTO objDTO)
        {
            try
            {
                ChiTietPhieuThueRepository Repo = new ChiTietPhieuThueRepository();
                Repo.CapNhat(objDTO);
            }
            catch (System.Exception )
            {
            }
        }

        public static List<ChiTietPhieuThueDTO> LayDanhSach()
        {
            List<ChiTietPhieuThueDTO> lst = new List<ChiTietPhieuThueDTO>();
            try
            {
                ChiTietPhieuThueRepository obj = new ChiTietPhieuThueRepository();
                lst = obj.LayDanhSach();
            }
            catch (System.Exception )
            {
            }
            return lst;
        }

        static public List<ChiTietPhieuThueDTO> LayDanhSach(int Start, int Record)
        {
             Data.ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
            return repo.LayDanhSach(Start, Record);
        }

        public static ChiTietPhieuThueDTO LayTheoMa(int MaChiTietPhieuThue)
        {
            ChiTietPhieuThueDTO objDTO = new ChiTietPhieuThueDTO();
            try
            {
                ChiTietPhieuThueRepository Repo = new ChiTietPhieuThueRepository();
                objDTO = Repo.LayTheoMa(MaChiTietPhieuThue);
            }
            catch (System.Exception )
            {
            }
            return objDTO;
        }

//
//Khoa ngoai PhieuThue
//
        static public List<ChiTietPhieuThueDTO> LayDanhSachTheoMaPhieuThue( int MaPhieuThue)
        {
             Data.ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
            return repo.LayDanhSachTheoMaPhieuThue( MaPhieuThue);
        }

        static public void XoaTheoMaPhieuThue( int MaPhieuThue, bool XoaKhoaNgoai=false)
        {
             Data.ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
            repo.XoaTheoMaPhieuThue( MaPhieuThue,XoaKhoaNgoai);
        }


//
//Khoa ngoai KhachHang
//
        static public List<ChiTietPhieuThueDTO> LayDanhSachTheoMaKhachHang( int MaKhachHang)
        {
             Data.ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
            return repo.LayDanhSachTheoMaKhachHang( MaKhachHang);
        }

        static public void XoaTheoMaKhachHang( int MaKhachHang, bool XoaKhoaNgoai=false)
        {
             Data.ChiTietPhieuThueRepository repo = new ChiTietPhieuThueRepository();
            repo.XoaTheoMaKhachHang( MaKhachHang,XoaKhoaNgoai);
        }

    }
}

